﻿@inherits DrawerTemplate<ResourceEditOption, bool>

@if (_editModel != null)
{
<Form Loading="@_isLoading"
      Model="@_editModel"
      LabelCol="new ColLayoutParam { Span = 8 }"
      WrapperCol="new ColLayoutParam { Span = 16 }"
      OnFinish="OnFormFinish"
      Context="model"
      Style="min-height:600px;">
    <FormItem Label="标示">
        <Input @bind-Value="@model.Id" Disabled />
    </FormItem>
    <FormItem Label="名称">
        <Input @bind-Value="@model.Name" />
    </FormItem>
    <FormItem Label="键值">
        <Input @bind-Value="@model.Key" />
    </FormItem>
    <FormItem Label="类型">
        <RadioGroup @bind-Value="@(model.Type)">

            @if (model.Id != Guid.Empty && model.Type.Equals(ResourceType.ROOT))
            {
                <Radio Value="@(ResourceType.ROOT)">@EnumExtension.GetEnumDescription(ResourceType.ROOT)</Radio>
            }
            else
            {
                foreach (var gitem in EnumExtension.EnumToDictionary<ResourceType>())
                {
                    if ((int)gitem.Key >= (int)_currentEditResourceType)
                    {
                        <Radio Value="@(gitem.Key)">@gitem.Value</Radio>
                    }
                }
            }
        </RadioGroup>
    </FormItem>
    @if (model.Type.Equals(ResourceType.API))
    {
        <FormItem Label="请求方法">
            <SimpleSelect @bind-Value="@_currentEditModelHttpMethodType"
                          DefaultValue="@((model.Method ?? HttpMethodType.GET).ToString())"
                          Style="width:120px;">
                <SelectOptions>
                    @foreach (var gitem in EnumExtension.EnumToDictionary<HttpMethodType>())
                    {
                        <SimpleSelectOption Value="@(gitem.Key.ToString())" Label="@(gitem.Value)"></SimpleSelectOption>
                    }
                </SelectOptions>
            </SimpleSelect>
        </FormItem>
    }
    <FormItem Label="地址">
        <Input @bind-Value="@model.Path" />
    </FormItem>
    <FormItem Label="图标">
        <Input @bind-Value="@model.Icon" />
    </FormItem>
    <FormItem Label="排序">
        <AntDesign.InputNumber @bind-Value="@model.Order" />
    </FormItem>
    <FormItem Label="是否锁定">
        <Switch @bind-Value="@model.IsLocked"></Switch>
    </FormItem>
    <FormItem Label="备注">
        <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Remark"></TextArea>
    </FormItem>
    <FormItem WrapperCol="new ColLayoutParam { Offset = 4, Span = 20 }">
        <Button Type="@ButtonType.Primary" HtmlType="submit">
            保存
        </Button>
        <Button OnClick="_ => OnFormCancel()">
            取消
        </Button>
    </FormItem>

</Form>
}